Skip to content

ci: allow running jobs locally#404466

Merged
Mic92 merged 8 commits intoNixOS:masterfrom
wolfgangwalther:ci-local
May 11, 2025
Merged

ci: allow running jobs locally#404466
Mic92 merged 8 commits intoNixOS:masterfrom
wolfgangwalther:ci-local

Conversation

@wolfgangwalther
Copy link
Copy Markdown
Contributor

@wolfgangwalther wolfgangwalther commented May 5, 2025

The goal is to be able to run nix-build ci locally to run (almost) all CI jobs. For contributors, but also for those who work on CI to easily test most of the CI code.

This first step already gets us a good step towards that goal. With the exception of the nixpks-vet workflow, which needs more preparation (starting in #405853), the main workflows can now be run with 3 commands:

  • nix-shell --run treefmt runs nixfmt, keep-sorted and editorconfig-checker. This was introduced in earlier PRs.
  • nix-build ci runs the check-shell, lib-tests, manual-nixos, manual-nixpkgs, nix-parse jobs just like in CI, but only for the local system, while CI runs some of them on different systems as well.
  • nix-build ci -A eval.full runs the eval jobs, as documented in the ci/eval/README.md file.

I think it doesn't make sense to run the full eval by default when doing nix-build ci, because most people would probably rather let CI do the big eval (?). The same goes for nix-build ci -A fmt.check, which runs the formatters - but I think it's more convenient to run the formatters via treefmt, which can benefit from caching.

While working on the parse check, I moved the nix-instantiate call inside the nix sandbox, thus allowing us to run the minimum nix version without security concerns, as discussed in #398122 (comment). While at it, we also parse with lix to make sure the many contributors using that will not suddenly get parse errors eventually (shouldn't happen, but you never know).

Things done

Ran nix-build ci --argstr system <system> for the below platforms.

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Test run in a fork's CI.
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@wolfgangwalther wolfgangwalther changed the base branch from nixpkgs-unstable to master May 5, 2025 20:02
@github-actions github-actions bot added 6.topic: python Python is a high-level, general-purpose programming language. 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: haskell General-purpose, statically typed, purely functional programming language 6.topic: qt/kde Object-oriented framework for GUI creation 6.topic: kernel The Linux kernel 8.has: changelog This PR adds or changes release notes 8.has: module (update) This PR changes an existing module in `nixos/` 6.topic: emacs Text editor 6.topic: printing Drivers, CUPS & Co. 6.topic: rust General-purpose programming language emphasizing performance, type safety, and concurrency. 6.topic: ruby A dynamic, open source programming language with a focus on simplicity and productivity. 6.topic: vim Advanced text editor 6.topic: erlang General-purpose, concurrent, functional high-level programming language 6.topic: ocaml OCaml is a general-purpose, high-level, multi-paradigm programming language. 6.topic: stdenv Standard environment 6.topic: nodejs Node.js is a free, open-source, cross-platform JavaScript runtime environment 6.topic: coq A formal proof management system 6.topic: lua Lua is a powerful, efficient, lightweight, embeddable scripting language. 6.topic: systemd Software suite that provides an array of system components for Linux operating systems. 6.topic: java Including JDK, tooling, other languages, other VMs 6.topic: R R is a programming language for statistical computing and data visualization. 6.topic: vscode A free and versatile code editor that supports almost every major programming language. 6.topic: lib The Nixpkgs function library 6.topic: games Gaming on NixOS 6.topic: php PHP is a general-purpose scripting language geared towards web development. 8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` 6.topic: k3s Kubernates distribution (https://k3s.io/) 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related 6.topic: dotnet Language: .NET labels May 5, 2025
@github-actions github-actions bot added backport release-24.11 and removed 6.topic: games Gaming on NixOS 6.topic: php PHP is a general-purpose scripting language geared towards web development. 8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` 6.topic: k3s Kubernates distribution (https://k3s.io/) 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related 6.topic: dotnet Language: .NET 6.topic: tcl Dynamic, multi-paradigm programming language 6.topic: teams Relating to team creation, updates, other management actions labels May 5, 2025
@github-actions github-actions bot added 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. labels May 5, 2025
They are not really related to eval.yml.
This allows running the lib-tests locally in exactly the same way that
they are run in CI:

  nix-build ci -A lib-tests
The NixOS manual can now be built locally the same way as in CI with:

  nix-build ci -A manual-nixos
The Nixpkgs manual can now be built locally the same way as in CI with:

  nix-build ci -A manual-nixpkgs -A manual-nixpkgs-tests
The dev shell can now be built locally the same way as in CI with:

  nix-build ci -A shell
The nix-parse workflow can now be run locally the same way as in CI.

To do this, the CI's workflow was slightly adjusted. Instead of testing
only the changed files, we're now testing all files in the repository.

This is possible in two ways:

1. By calling nix-instantiate once with all files as arguments. This
will be rather fast, but only the first error is shown before it errors
out.
2. By calling nix-instantiate once for each file. This will be much
slower, but has the advantage that we see all errors at once.

To avoid running the long variant every time, we first do a quick check
with the fast version. If that fails, we run the slower one to report
the errors. This gives us the best of both.
Path interpolation syntax is not supported in the minimum nix version.
This adds the minimum nix version and the latest lix version to the
matrix of parse checks. Especially the minimum nix version is relevant,
because parsing routinely breaks because of introduction of newer
syntax.

Adding lix just completes the picture.
@nixpkgs-ci
Copy link
Copy Markdown
Contributor

nixpkgs-ci bot commented May 11, 2025

Successfully created backport PR for release-24.11:

@wolfgangwalther
Copy link
Copy Markdown
Contributor Author

Hm, the calls in the workflows were not correct, yet, apparently. Some CI jobs are failing now. Will fix ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: continuous integration Affects continuous integration (CI) in Nixpkgs, including Ofborg and GitHub Actions 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: policy discussion Discuss policies to work in and around Nixpkgs 8.has: port to stable This PR already has a backport to the stable release. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants